package com.eshop.modules.mp.handler;

import me.chanjar.weixin.mp.builder.outxml.TextBuilder;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import java.util.Map;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import org.springframework.stereotype.Component;

@Component
public class MenuHandler extends AbstractHandler
{
    public WxMpXmlOutMessage handle(final WxMpXmlMessage wxMessage, final Map<String, Object> context, final WxMpService weixinService, final WxSessionManager sessionManager) {
        final String msg = String.format("type:%s, event:%s, key:%s", wxMessage.getMsgType(), wxMessage.getEvent(), wxMessage.getEventKey());
        if ("view".equals(wxMessage.getEvent())) {
            return null;
        }
        return (WxMpXmlOutMessage)((TextBuilder)((TextBuilder)WxMpXmlOutMessage.TEXT().content(msg).fromUser(wxMessage.getToUser())).toUser(wxMessage.getFromUser())).build();
    }
}
